<?php

namespace App\Http\Controllers\Backend\Student;

use App\Http\Models\User\UserService;
use Illuminate\Http\Request;
use App\Http\Models\Student\StudentFrom;
use App\Http\Models\Student\StudentService;
use App\Http\Controllers\Backend\BackendController;

class StudentController extends BackendController
{

    /**
     * StudentController 学员列表
     *
     * @author Jinfeihu
     *
     * */
    private $studentService;
    private $request;

    public function __construct(StudentService $studentService, Request $request)
    {
        $this->studentService = $studentService;
        $this->request = $request;
    }

    public function index()
    {
        $studentDatas = $this->studentService->index($this->request);
        return view("backend.student.index", [
            'studentDatas' => $studentDatas,
            'request'      => $this->request
        ]);
    }

    public function edit($id)
    {

        $dancesList =(new UserService())->getPrivateEducation();
        $leagueDances = $this->studentService->getLeagueDances();
        $studentData = $this->studentService->show($id);
        return view('backend.student.update', [
            'studentData'  => $studentData,
            'dancesList'   => $dancesList,
            'leagueDances' => $leagueDances,
            'dances'=>DANCE
        ]);
    }

    public function update(StudentFrom $rotaionFrom, $id)
    {
        $this->studentService->updateSave($rotaionFrom, $id);
        return redirect('admin/student');
    }

    public function buyLogView($id)
    {
        $studentBuyDatas = $this->studentService->getBuyLog($id);
        return view('backend.student.student_buy_log_index', [
            'studentBuyDatas' => $studentBuyDatas
        ]);
    }

    public function destroy($id)
    {
        return $this->studentService->remove($id);
    }

    public function buyLogDelete($id)
    {
        return $this->studentService->buyLogDelete($id);
    }

}
